#include "stk_accept.h"

using namespace stk;

Accept::Accept()
{
    SetType(STK_FD_NAME_ACCEPT);

    m_value = "";
}

Accept::Accept(const Accept &src)
{
    *this = src;
}

Accept::Accept(const char *buf, int len)
{
    SetType(STK_FD_NAME_ACCEPT);
    parse(buf, len);
}

Accept::~Accept()
{
    clear();
}

bool Accept::isvalid() const
{
    return !m_value.empty();
}

void Accept::clear()
{
    m_value = "";
}

int32_t Accept::to_str (string &str)
{
    str += m_value;

    return 0;
}

int32_t Accept::parse (const char *buf, int len)
{
    if (!buf)
    {
        printf("ERRO: <%010d> <%s.Parse> Invalid Buffer\n", GetSession(), GetTypeName());
        return -1;
    }

    clear();

    m_value = buf;

    return 0;
}

Accept& Accept::operator = (const Accept &src)
{
    clear();

    m_value = src.m_value;
    MsgField::operator=(src);

    return *this;
}
